package com.lgqz.himalayafm.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.lgqz.himalayafm.R;

public class WebViewActivity extends AppCompatActivity {
    private WebView webView;
    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_view);
        webView = (WebView) findViewById(R.id.web_view);
        textView= (TextView) findViewById(R.id.webview_textview);
        Intent intent = getIntent();
        String webUrl = intent.getStringExtra("webUrl");
        // 设置内嵌app中的网页客户端（处理展示操作）
        webView.setWebViewClient(new WebViewClient());
        webView.setWebChromeClient(new WebChromeClient(){
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);

                if (!TextUtils.isEmpty(title)) {
                    textView.setText(title);
                }
            }
        });
        //加载网页
        webView.loadUrl(webUrl);

    }


    @Override
    public void onBackPressed() {
        Intent intent = new Intent(WebViewActivity.this, MainActivity.class);
        startActivity(intent);
        super.onBackPressed();
    }
    public void clickBtn(View view){
        Intent intent=new Intent(WebViewActivity.this,MainActivity.class);
        startActivity(intent);
        finish();

    }

}
